home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-30 | 3.3 KB | 106 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LAGATextButton.cp
- // ===========================================================================
- // “Apple Grayscale Appearance” compliant text button
- // Copyright © 1996 Chrisoft (Christophe ANDRES) All rights reserved.
- //
- // You may use this source code in any application (commercial, shareware, freeware,
- // postcardware, etc), but not remove this notice (no need to acknowledge the use of
- // this class in the about box)
- // You may not sell this source code in any form. This source code may be placed on
- // publicly accessable archive sites and source code disks. It may not be placed on
- // profit archive sites and source code disks without the permission of the author,
- // Christophe ANDRES.
- //
- // This source code is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- //
- // If you make any change or improvement on this class, please send the improved/changed
- // version to : chrisoft@calva.net or Christophe ANDRES
- // 20, rue Prosper Mérimée
- // 67100 STRASBOURG
- // FRANCE
- //
- // ===========================================================================
- // LAGATextButton.h <- double-click + Command-D to see class implementation
- //
- // LAGATextButton is a replacement class for LTextButton, that is needed, because in CW9 (PP 1.4)
- // the LTextButton::DrawSelf doesn't use ApplyForeAndBackColors anymore, so that ::DrawText
- // puts a white background under the text, which is of course bad for a non-white background
- // window
- //
- // Version : 1.2
- //
- // Change History (most recent first, date in US form : mm/dd/yy):
- //
- // 06/30/96 ca Public release of version 1.2
- // 06/29/96 ca class made available by Christophe ANDRES <chrisoft@calva.net>
- // (version 1.2 to be consistent with the other classes)
- //
- // To Do:
- //
-
-
- #include "LAGATextButton.h"
-
- void LAGATextButton::RegisterClass ()
-
- {
- URegistrar::RegisterClass(LAGATextButton::class_ID, (ClassCreatorFunc)LAGATextButton::CreateAGATextButtonStream);
- }
-
- LAGATextButton* LAGATextButton::CreateAGATextButtonStream (LStream *inStream)
-
- {
- return(new LAGATextButton(inStream));
- }
-
- LAGATextButton::LAGATextButton ()
-
- {
- }
-
- LAGATextButton::LAGATextButton (LStream* inStream) : LTextButton(inStream)
-
- {
- }
-
- void LAGATextButton::DrawSelf ()
-
- {
- StTextState origTextState;
- StColorPenState origCPenState;
-
- // Configure the text state. If the button is selected,
- // modify the text style.
-
- Int16 theJust = UTextTraits::SetPortTextTraits(mTextTraitsID);
- if (mValue != Button_Off)
- {
- GrafPtr currPort = UQDGlobals::GetCurrentPort();
- Int16 currStyle = currPort->txFace;
- ::TextFace(currStyle ^ mSelectedStyle);
- }
-
- // Draw the text.
-
- Rect theFrame;
- CalcLocalFrameRect(theFrame);
-
- if (theJust == teFlushDefault)
- {
- theJust = ::GetSysDirection();
- }
-
- // Set background color
-
- RGBColor textColor; // Text has its own foreground color
- ::GetForeColor(&textColor);
-
- ApplyForeAndBackColors();
- ::RGBForeColor(&textColor);
-
- UTextDrawing::DrawWithJustification((Ptr)&mText[1], mText[0],
- theFrame, theJust);
- }